<?php

namespace Apps\AppApi\Method\Note;


use Apps\AppApi\Method\BaseMethod;
use Apps\Common\Models\Inorout;
use PhalconPlus\Api\Common\ResultStatus;

/**
 * 删除分类
 * @author      545
 * @date        2016年1月12日
 * @version     1.1.2
 * @copyright   Copyright 2015 meelier.com
 */
class DeleteInorout extends BaseMethod
{
    public function run()
    {
    	if(false == $this->verifyUserAuth()){
    		return false;
    	}
    	$inorout_id = $this->getDataItem('inorout_id',0);
    	
    	if ($inorout_id == 0 ){
    	    return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR,"业务数据不全");
    	}
    	
    	$userId = $this->getUserAuth()->userId;
    	$inorout = Inorout::findFirst("inorout_id = {$inorout_id} and user_id = {$userId} ");
    	
    	if($inorout){

    	    if ($inorout->delete()){
    	        $this->setResult(['success'=>1,'message'=>'删除成功！']);
    	    }
    		else {
    		    $this->setResult(['success'=>0,'message'=>'删除失败！']);
    		}
    	}else{
    		$this->setResult(['success'=>0,'message'=>'删除失败！']);
    	}
    }
}